/*
 * 判断一个整型数据有几位v2.0（4分）
 *
 * v1.0，见：05-week05/11_Determine_How_Many_Digits_The_Integer_Has_v1.c
 */

#include <stdio.h>

int main() {
	setbuf(stdout, NULL);

	int input, flag = 0;
	int temp, numberical_digits = 0, flags[10] = {0};

	printf("Please enter the number:\n");
	scanf("%d", &input);

	if (input < 0) {
		input = -input;
		flag =1;
	}

	temp = input;

	while (temp > 0) {
		++numberical_digits;
		++flags[temp % 10];

		temp /= 10;
	}

	// 输出总体信息
	if (flag == 0) {
		printf("%d: %d bits\n", input, numberical_digits);
	} else {
		printf("%d: %d bits\n", -input, numberical_digits);
	}
	// 输出逐位信息
	for (int i = 0; i < 10; ++i) {
		if (flags[i] == 0) {
			continue;
		} else {
			printf("%d: %d\n", i, flags[i]);
		}
	}

	return 0;
}